#!/bin/bash

# 检查输入参数
if [ "$#" -ne 3 ]; then
    echo "Usage: $0 <hostname> <port> <hex_string>"
    exit 1
fi

# 读取参数
IP=$1
PORT=$2
HEXDATA=$3

# 使用xxd工具从十六进制字符串生成二进制数据并发送
# echo $HEX_STRING | xxd -r -p | nc $HOST $PORT
echo $HEXDATA | xxd -r -p | nc $IP $PORT | xxd -p


# ./send_hex.sh 127.0.0.1 port 28124E00000000000C00030

# ./send_hex.sh 58.20.129.6 19808 28124E00000000000C00030


# ./send_hex.sh 124.71.202.179 10001  7E0100002C0153135860220000002B006431303031303236394A540000000000000000000000000000000153135860220000D0C53030303100657E


# python3 demo.py 

# netstat -tulnp | grep ':10001' | awk '{print $7}' | cut -d'/' -f1 | xargs kill

# ps -ef | grep python  | grep -v grep  | awk '{print $2}' | xargs kill -9 

